package pack0702.cn;

import java.util.Scanner;

public class Game {
    public static void main(String[] args) {

        UserManager u =new UserManager();
        System.out.println("--------------------------");
        System.out.println("--------欢迎进入游戏--------");
        System.out.println("--------------------------");
        Scanner scan=new Scanner(System.in);
        System.out.println("输入名字: ");
        String name= scan.next();
        System.out.println("输入密码: ");
        String pass= scan.next();

//        boolean flag=true;
//        for (int i = 0; i < u.users.length; i++) {
//            User us = u.users[i];
//            if(us.getName().equals(name)&&us.getPass().equals(pass)){
//              //合法用户
//                flag=true;
//                break;
//            }else{
//                flag=false;
//            }
//        }
//        if(flag)
//            System.out.println("登陆成功");
//        else
//            System.out.println("用户名或者密码错误");

        boolean flag=true;
        for (int i = 0; i < u.users.length; i++) {
            User us = u.users[i];
            if(us.equals(new User(name,pass))){
                //合法用户
                flag=true;
                break;
            }else
                flag=false;
        }
        if(flag)
            System.out.println("登陆成功");
        else
            System.out.println("用户名或者密码错误");

}
}
